/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidades;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author Andres
 */
@Entity
@Table(name = "RESERVARESTAURANTE", catalog = "", schema = "PROYECTO", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"CONF_PERSONA_CODPE"})})
@NamedQueries({
    @NamedQuery(name = "Reservarestaurante.findAll", query = "SELECT r FROM Reservarestaurante r"),
    @NamedQuery(name = "Reservarestaurante.findByReservaCodigoreserva", query = "SELECT r FROM Reservarestaurante r WHERE r.reservarestaurantePK.reservaCodigoreserva = :reservaCodigoreserva"),
    @NamedQuery(name = "Reservarestaurante.findByConfPersonaCodpe", query = "SELECT r FROM Reservarestaurante r WHERE r.reservarestaurantePK.confPersonaCodpe = :confPersonaCodpe")})
public class Reservarestaurante implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ReservarestaurantePK reservarestaurantePK;
    @JoinColumn(name = "RESERVA_CODIGORESERVA", referencedColumnName = "CODIGORESERVA", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Reserva reserva;

    public Reservarestaurante() {
    }

    public Reservarestaurante(ReservarestaurantePK reservarestaurantePK) {
        this.reservarestaurantePK = reservarestaurantePK;
    }

    public Reservarestaurante(int reservaCodigoreserva, int confPersonaCodpe) {
        this.reservarestaurantePK = new ReservarestaurantePK(reservaCodigoreserva, confPersonaCodpe);
    }

    public ReservarestaurantePK getReservarestaurantePK() {
        return reservarestaurantePK;
    }

    public void setReservarestaurantePK(ReservarestaurantePK reservarestaurantePK) {
        this.reservarestaurantePK = reservarestaurantePK;
    }

    public Reserva getReserva() {
        return reserva;
    }

    public void setReserva(Reserva reserva) {
        this.reserva = reserva;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (reservarestaurantePK != null ? reservarestaurantePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Reservarestaurante)) {
            return false;
        }
        Reservarestaurante other = (Reservarestaurante) object;
        if ((this.reservarestaurantePK == null && other.reservarestaurantePK != null) || (this.reservarestaurantePK != null && !this.reservarestaurantePK.equals(other.reservarestaurantePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Reservarestaurante[reservarestaurantePK=" + reservarestaurantePK + "]";
    }

}
